package com.xiaobai.java_core.oop;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author 王天文
 * @Date 2024/12/7 20:27
 * @Description: 冰箱类
 */
@Slf4j
public class Refrigerator {

    /**
     * 冰箱门是否打开
     */
    private boolean isOpen;

    /**
     * 是否有大象
     */
    private boolean hasElephant;

    public Refrigerator() {
        this.isOpen = false;

        this.hasElephant = false;
    }

    /**
     * 打开冰箱门
     */
    public void open() {
        this.isOpen = true;
        log.info("打开冰箱门");
    }

    /**
     * 将大象放进冰箱
     */
    public void putElephant() {
        if (isOpen) {
            this.hasElephant = true;
            log.info("将大象放进冰箱");
        } else {
            log.info("请先打开冰箱门");
        }
    }

    /**
     * 关闭冰箱门
     */
    public void close() {
        this.isOpen = false;
        log.info("冰箱门已关闭");
    }
}
